package com.by.controller;

import com.by.biz.AirBiz;
import com.by.pojo.Air;
import com.by.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class AirController {

    @Autowired
    private AirBiz airBiz;

@RequestMapping("/getAirByPage")
    public String getAirByPage(Model model,Integer currPage){
    /*第一次访问当前页是零*/
    if(currPage==null){
        currPage=1;
    }

        Map<String ,Object> map =new HashMap<String ,Object>();
        map.put("begin",PageUtil.PAGE_SIZE*(currPage-1));
        map.put("len", PageUtil.PAGE_SIZE);
        List<Air> list= airBiz.getAirByPage(map);
        model.addAttribute("currPage",currPage);
        model.addAttribute("list",list);
        return "airlist";
    }

}
